package com.app.service.impl;

import com.app.entity.Course;
import com.app.entity.Evaluation;
import com.app.mapper.EvaluationMapper;
import com.app.service.EvaluationService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yeyuan
 * @since 2021-12-28
 */
@Service
public class EvaluationServiceImpl extends ServiceImpl<EvaluationMapper, Evaluation> implements EvaluationService {

    @Override
    public List<Evaluation> getListByCid(Long cid) {
        //
        LambdaQueryWrapper<Evaluation> wrapper = new LambdaQueryWrapper<>();
        //根据课程id获取
        wrapper.eq(ObjectUtils.isNotNull(cid),Evaluation::getCId,cid);
        return getBaseMapper().selectList(wrapper);
    }

    @Override
    public int addEvaluation(Evaluation evaluation) {
        return getBaseMapper().insert(evaluation);
    }


}
